From 42b9b2782312c50dfc5901560ee3f5f174358846 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Fri, 22 Apr 2011 20:17:21 +0000 Subject: [PATCH] Followup to r86312 Reedy: that rev is breaking usage of {{PAGENAME}} in messages, such as in MediaWiki:Noarticles Allowing optional passing in of a Title object (like it may be set in Message), but if it's not set, or not a title object, fall back and use $wgTitle (I'm sorry!) --- includes/GlobalFunctions.php | 6 +++--- includes/Message.php | 2 +- includes/MessageCache.php | 9 ++++++--- includes/search/SearchEngine.php | 3 +++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index e69d3e2f5a..b0ef842897 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -736,7 +736,7 @@ function wfMsgWikiHtml( $key ) { $args = func_get_args(); array_shift( $args ); return wfMsgReplaceArgs( - MessageCache::singleton()->parse( wfMsgGetKey( $key, true ), $key, /* can't be set to false */ true )->getText(), + MessageCache::singleton()->parse( wfMsgGetKey( $key, true ), null, /* can't be set to false */ true )->getText(), $args ); } @@ -798,9 +798,9 @@ function wfMsgExt( $key, $options ) { $messageCache = MessageCache::singleton(); if( in_array( 'parse', $options, true ) ) { - $string = $messageCache->parse( $string, $key, true, !$forContent, $langCodeObj )->getText(); + $string = $messageCache->parse( $string, null, true, !$forContent, $langCodeObj )->getText(); } elseif ( in_array( 'parseinline', $options, true ) ) { - $string = $messageCache->parse( $string, $key, true, !$forContent, $langCodeObj )->getText(); + $string = $messageCache->parse( $string, null, true, !$forContent, $langCodeObj )->getText(); $m = array(); if( preg_match( '/^

(.*)\n?<\/p>\n?$/sU', $string, $m ) ) { $string = $m[1]; diff --git a/includes/Message.php b/includes/Message.php index d65ec86805..d4ea091c56 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -432,7 +432,7 @@ class Message { * @return string Wikitext parsed into HTML */ protected function parseText( $string ) { - return MessageCache::singleton()->parse( $string, $this->key, /*linestart*/true, $this->interface, $this->language )->getText(); + return MessageCache::singleton()->parse( $string, $this->title, /*linestart*/true, $this->interface, $this->language )->getText(); } /** diff --git a/includes/MessageCache.php b/includes/MessageCache.php index 34eaa6d3cc..a498fca0a9 100644 --- a/includes/MessageCache.php +++ b/includes/MessageCache.php @@ -791,12 +791,13 @@ class MessageCache { /** * @param $text string * @param $string Title|string + * @param $title Title * @param $interface bool * @param $linestart bool * @param $language * @return ParserOutput */ - public function parse( $text, $key, $linestart = true, $interface = false, $language = null ) { + public function parse( $text, $title = null, $linestart = true, $interface = false, $language = null ) { if ( $this->mInParser ) { return htmlspecialchars( $text ); } @@ -811,9 +812,11 @@ class MessageCache { $popts->setTargetLanguage( $language ); } - if ( !($key instanceof Title) ) { - $title = Title::newFromText( $key, NS_MEDIAWIKI ); + if ( !$title || !$title instanceof Title ) { + global $wgTitle; + $title = $wgTitle; } + $this->mInParser = true; $res = $parser->parse( $text, $title, $popts, $linestart ); $this->mInParser = false; diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 4ef728a2e9..435480a775 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -616,6 +616,9 @@ class SearchResultSet { * This class is used for different SQL-based search engines shipped with MediaWiki */ class SqlSearchResultSet extends SearchResultSet { + + private $mResultSet; + function __construct( $resultSet, $terms ) { $this->mResultSet = $resultSet; $this->mTerms = $terms; -- 2.20.1